/****************************************************************************
**
** Copyright (C) 2010 FPT University FUEMES group.
** All rights reserved.
** Contact: FPT University http://www.fpt.edu.vn
**
** This file is part of the demonstration applications of the FUEMES mini2440 client
**
** $FUEMES_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** FUEMES group at fuemes@gmail.com.
** $FUEMES_END_LICENSE$
**
****************************************************************************/
#ifndef MINI2440CONFIGURATION_H
#define MINI2440CONFIGURATION_H
#include <qstring.h>
#include "common.h"
#include <qfile.h>

/*
<?xml version='1.0' encoding='utf-8'?>
<mini2440>
    <server ip="127.0.0.1"  port="8888">
    </server>

    <screensave interval="1000" timeout="6000">
        <imagedir dir="slides/qt"/>
    </screensave>

    <messageslideshow interval="1000">
        <imagedir dir="slides/message"/>
    </messageslideshow>

    <password>
        <default value="12345678"/>
        <current value="11111111"/>
    </password>

    <setting>
        <screensave interval="3" delay="3"/>
        <autolock value="3"/>
        <language name="日本語"/>
    </setting>
</mini2440>
*/
class mini2440Configuration
{
private:
        QString         m_serverIP;
        unsigned int    m_serverPort;
        int             m_screenInterval;
        int             m_screenTimeout;
        QString         m_screenImageDir;

        int             m_messageInterval;
        QString         m_messageImageDir;

        QString         m_defaultPassword;
        QString         m_currentPassword;

        unsigned int    m_autolock;
        QString         m_language;

        QDomDocument    m_domDocument;

public:
    mini2440Configuration();
    bool loadConfig();
    bool saveConfig();

    QString get_currentPass();
    void set_currentPass(QString currentPass);

    QString get_language();
    void set_language(QString language);

    unsigned int get_autolock();
    void set_autolock(unsigned int autolock);

    int get_screenInterval();
    void set_screenInterval(int screenInterval);

    int get_screenTimeout();
    void set_screenTimeout(int screenTimeout);

    unsigned int getServerPort();
    QString getServerIP();
    QString getScreenImageDir();
    QString getMessageImageDir();

    void resetPass();
protected:
    void parseServerInfo(QXmlStreamReader& reader);
    void parseScreenSave(QXmlStreamReader& reader);
    void parseMessageSlideShow(QXmlStreamReader& reader);
    void parsePassword(QXmlStreamReader& reader);
    void parseOther(QXmlStreamReader& reader);
};

#endif // MINI2440CONFIGURATION_H
